package org.ccnetconfig.ccdroid;

import java.util.LinkedList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;

public class ProjectAdapter extends BaseAdapter {
	private Context							context		= null;
	private LinkedList<Project>	projects	= null;

	public ProjectAdapter ( Context context, LinkedList<Project> projects ) {
		this.setContext ( context );
		this.setProjects ( projects );
	}

	public int getCount ( ) {
		return this.getProjects ().size ();
	}

	public Project getItem ( int position ) {
		return this.getProjects ().get ( position );
	}

	public long getItemId ( int position ) {
		return this.getItem ( position ).getId ();
	}

	public View getView ( int position, View convertView, ViewGroup parent ) {
		if ( convertView != null ) {
			return (LinearLayout) convertView;
		} else {
			LinearLayout ll = new LinearLayout ( this.getContext () );

			return ll;
		}
	}

	/**
	 * @param context
	 *          the context to set
	 */
	public void setContext ( Context context ) {
		this.context = context;
	}

	/**
	 * @return the context
	 */
	public Context getContext ( ) {
		return context;
	}

	/**
	 * @param projects
	 *          the projects to set
	 */
	public void setProjects ( LinkedList<Project> projects ) {
		this.projects = projects;
	}

	/**
	 * @return the projects
	 */
	public LinkedList<Project> getProjects ( ) {
		return projects;
	}

}
